#include<bits/stdc++.h>
using namespace std;
#define ll long long

int power[200010];
vector<int> graph[200010];
int visited[200010];
int Distance[200010];
int n, m, R, dis;


int bfs(int x){
    for (int i = 0; i <= n; i++){
        visited[i] = 0;
        Distance[i] = -1;
    }
    queue<int> que;
    que.push(1);
    visited[1] = 1;
    Distance[1] = 0;
    while (!que.empty()){
        int qSize = que.size();
        for (int i = 0; i < qSize; i++){
            int temp = que.front();
            que.pop();
            for (int i = 0; i < graph[temp].size(); i++){
                if (power[graph[temp][i]] < x && !visited[graph[temp][i]]){
                    visited[graph[temp][i]] = 1; // ！不允许走回头路
                    Distance[graph[temp][i]] = Distance[temp] + 1;
                    que.push(graph[temp][i]);
                }
                
            }
        }
    }
    return Distance[n];
}

int bs(int l, int r){
    if (l == r) return l;
    int mid = (l + r) / 2;
    int tempmids = bfs(R + mid);
    if (tempmids != -1 && tempmids <= dis) return bs(l, mid);
    return bs(mid + 1, r);
}



int main(){
    freopen("demo.txt", "r", stdin);
    // n 图的点数
    // m 图的边数
    // R 小红初始战斗力
    // dis 小红最多想走的路程。
    cin >> n >> m >> R >> dis;
    // 输入怪兽战力
    for (int i = 1; i <= n; i++) cin >> power[i];
    // 建图
    while (m--){
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    int op = bfs(R);
    int ed = bfs(1e9);
    if (op != -1 && op <= dis){
        cout << 0;
        return 0;
    }
    if (ed > dis || ed == -1){
        cout << -1;
        return 0;
    }
    cout << bs(0, 1e9);
}